#include<iostream>
using namespace std;
int main(){
  int a,b,c,d,t,h,m;
  cin>>a>>b>>c>>d;
  t=60*(c-a)+(d-b);
  h=t/60;
  m=t%60;
  cout<<h<<" "<<m;
}